using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Resources.SqlResource;

public partial class _Default : System.Web.UI.Page 
{

    protected void Page_Load(object sender, EventArgs e)
    {
        lblTest.Text = HttpContext.Current.Cache.Count.ToString();
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        SqlResourceSet rs = new SqlResourceSet(new System.Globalization.CultureInfo("it-it"));
        lblITA.Text = rs.GetString("Param_1002");

        rs = new SqlResourceSet(new System.Globalization.CultureInfo("en-us"));
        lblENG.Text = rs.GetString("Param_1002");

        rs = new SqlResourceSet(new System.Globalization.CultureInfo("it-ch"));
        lblDEF.Text = rs.GetString("Param_1002");

        lblTest.Text = HttpContext.Current.Cache.Count.ToString();
    }
    protected void btn_Test_Write_Click(object sender, EventArgs e)
    {
        SqlResourceWriter rw = new SqlResourceWriter(new System.Globalization.CultureInfo("it-it"));
        rw.AddResource("Param_1002", "Val_Param_1002_ITA_PIE");
        rw.AddResource("Param_1002", 123);
    }
    protected void btn_TestSendFile_Click(object sender, EventArgs e)
    {
        SqlResourceWriter rw = new SqlResourceWriter(new System.Globalization.CultureInfo("it-it"));
        rw.AddResource("Param_1002", fileTestSendFile.FileBytes);
    }
    protected void btn_TestSendImg_Click(object sender, EventArgs e)
    {
        SqlResourceWriter rw = new SqlResourceWriter(new System.Globalization.CultureInfo("it-it"));
        System.IO.Stream s = file_TestSendImg.FileContent;
        System.Drawing.Bitmap b = new System.Drawing.Bitmap(s);
        s.Flush();
        
        rw.AddResource("Param_1002", b);
        s.Close();
    }
    protected void btn_delResource_Click(object sender, EventArgs e)
    {
        SqlResourceWriter rw = new SqlResourceWriter(new System.Globalization.CultureInfo("it-it"));
        rw.DeleteResource("Param_1002");
    }
    protected void btn_getObj_Click(object sender, EventArgs e)
    {
        SqlResourceSet rs = new SqlResourceSet(new System.Globalization.CultureInfo("it-it"));
        object o = rs.GetObject("Param_1002",true);
        System.Drawing.Bitmap b = (System.Drawing.Bitmap)o;
        b.Save("c:\\tmp.gif");
        b.Dispose();
    }
    protected void btn_TestRM_Click(object sender, EventArgs e)
    {
        SqlResourceManager rm = new SqlResourceManager();
        lbl_TestRM.Text = rm.GetString("Param_1001");
        lbl_TestRM.Text = rm.GetString("Param_1001", new System.Globalization.CultureInfo("it-it"));
    }
}
